#freeslay - by Rafael and Karlisson

import pygame, sys, colors
import random
from grid import Grid
from logic import GameLogic
from menu import Menu

def main():

    pygame.init()
    surface = pygame.display.set_mode((800, 600))
    pygame.mouse.set_visible(1)
    pygame.display.update()
    pygame.display.flip()

    gamelogic = GameLogic()
    grid = Grid(surface, 35, 31, gamelogic)
    menu = Menu(surface)

    menu.draw(gamelogic)

    while True:
        for event in pygame.event.get():
            grid.mouse_posevent(pygame.mouse.get_pos())

            if pygame.mouse.get_pressed()[0] == True:
                if gamelogic.mode == 'putunit':
                    grid.mouse_putinit_event(pygame.mouse.get_pos(), gamelogic.current_nation_index)
                if gamelogic.mode == 'select':
                    grid.mouse_select_event(pygame.mouse.get_pos(),gamelogic.current_nation_index)

            if pygame.key.get_pressed()[pygame.K_RETURN]:
                gamelogic.next_turn()
                menu.draw(gamelogic)

            if event.type == pygame.QUIT:
                sys.exit(0)



if __name__ == "__main__":
    main()
